import router from '@system.router';
import tabbarItems from '../../common/datas/tabbarItem.js';

export default {
    data: {
        tabbarItems,
        title: "",
        index : 0,
        display1: 'flex',
        display2: 'none',
        display3: 'none',
        display4: 'none',
    },

    onShow(){
        // 从其他页面跳转回来，清除页面栈
        router.clear();
    },


    props:{
        index:{
            type: Number,
            default(){
                return 0;
            }
        }
    },

    change(e) {

        if (e.currentTarget.attr.value === '首页') {
            this.index = 0;
            this.function1();
        } else if (e.currentTarget.attr.value === '历史数据') {
            this.index = 1;
            this.function2();
        } else if (e.currentTarget.attr.value === '设备') {
            this.index = 2;
            this.function3();
        } else if (e.currentTarget.attr.value === '我的') {
            this.index = 3;
            this.function4();
        }
    },

    function1() {
        this.display1 = 'flex';
        this.display2 = 'none';
        this.display3 = 'none';
        this.display4 = 'none';
    },
    function2() {
        this.display1 = 'none';
        this.display2 = 'flex';
        this.display3 = 'none';
        this.display4 = 'none';
    },
    function3() {
        this.display1 = 'none';
        this.display2 = 'none';
        this.display3 = 'flex';
        this.display4 = 'none';
    },
    function4() {
        this.display1 = 'none';
        this.display2 = 'none';
        this.display3 = 'none';
        this.display4 = 'flex';
    }

}
